﻿CREATE TABLE [CO].[Manufacturers] (
    [Id]        INT           NOT NULL,
    [CountryId] INT           CONSTRAINT [DF__Manufactu__Count__02084FDA] DEFAULT ((1)) NULL,
    [Name]      VARCHAR (100) NOT NULL,
    [ShortName] VARCHAR (50)  NOT NULL,
    [LatName]   VARCHAR (50)  NULL,
    [Note]      VARCHAR (250) NULL,
    [MD]        DATETIME      CONSTRAINT [DF__Manufacturer__MD__02FC7413] DEFAULT (getdate()) NOT NULL,
    [MW]        VARCHAR (50)  CONSTRAINT [DF__Manufacturer__MW__03F0984C] DEFAULT (suser_sname()) NOT NULL,
    [ToDelete]  BIT           DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_Manufacturers] PRIMARY KEY CLUSTERED ([Id] ASC),
    CONSTRAINT [FK_Manufacturers_Countries] FOREIGN KEY ([CountryId]) REFERENCES [CO].[Countries] ([Id]) ON UPDATE CASCADE
);


GO
CREATE NONCLUSTERED INDEX [IX_Manufacturers_Name]
    ON [CO].[Manufacturers]([Name] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Manufacturers_ShortName]
    ON [CO].[Manufacturers]([ShortName] ASC);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Признак того, что запись нужно удалить из БД всех подразделений', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'Manufacturers', @level2type = N'COLUMN', @level2name = N'ToDelete';

